package com.ibm.law.ui.system.setup;

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.PojoProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import com.ibm.law.domain.ChargeItem;
import com.ibm.law.service.system.ChargeItemService;
import com.ibm.law.ui.common.CloseDialogSelectionAdapter;

public class ChargeItemAddDialog extends Dialog {
	private DataBindingContext m_bindingContext;
	
	protected Object result;
	protected Shell shell;
	private Text text;
	private Text text_1;
	private Label lblNewLabel_1;
	private Label lblNewLabel_2;
	private Text text_2;
	private Label lblNewLabel_3;
	private Text text_3;
	private Group group;
	private Label lblNewLabel_4;
	private Text text_4;
	private Text text_5;
	private Text text_6;
	private Label lblNewLabel_7;
	private Text text_7;
	private Combo combo_3;
	private Text text_8;
	private Label lblNewLabel_8;
	private Combo combo_4;
	private Label lblNewLabel_9;
	private Text text_9;
	private Combo combo_5;
	private Text text_10;
	private Label lblNewLabel_10;
	private Combo combo_6;
	private Label lblNewLabel_11;
	private Text text_11;
	private Button btnNewButton;
	private Button btnNewButton_1;
	
	private ChargeItem chargeItem;
	public ChargeItem getChargeItem() {
		return chargeItem;
	}

	public void setChargeItem(ChargeItem chargeItem) {
		this.chargeItem = chargeItem;
	}
	private Combo combo_1;
	private Combo combo;
	private Combo combo_2;
	
	/**
	 * Create the dialog.
	 * @param parent
	 * @param style
	 */
	public ChargeItemAddDialog(Shell parent, int style) {
		super(parent, style);
		setText("SWT Dialog");
	}

	/**
	 * Open the dialog.
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}

	/**
	 * Create contents of the dialog.
	 */
	private void createContents() {
		shell = new Shell(getParent(), getStyle());
		shell.setSize(490, 392);
		shell.setText("收费项目");
		GridLayout gl_shell = new GridLayout(4, false);
		gl_shell.marginLeft = 10;
		gl_shell.marginRight = 10;
		shell.setLayout(gl_shell);
		
		Label lblNewLabel = new Label(shell, SWT.NONE);
		lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel.setText("收费项目");
		
		text = new Text(shell, SWT.BORDER);
		text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		
		lblNewLabel_1 = new Label(shell, SWT.NONE);
		lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel_1.setText("单位");
		
		text_1 = new Text(shell, SWT.BORDER);
		text_1.setText("");
		text_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		
		lblNewLabel_2 = new Label(shell, SWT.NONE);
		lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel_2.setText("基准价（元）");
		
		text_2 = new Text(shell, SWT.BORDER);
		text_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		lblNewLabel_3 = new Label(shell, SWT.NONE);
		lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel_3.setText("标准收费（元）");
		
		text_3 = new Text(shell, SWT.BORDER);
		text_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		group = new Group(shell, SWT.NONE);
		group.setText("绩效津贴");
		GridData gd_group = new GridData(SWT.FILL, SWT.CENTER, false, false, 4, 1);
		gd_group.widthHint = 436;
		group.setLayoutData(gd_group);
		group.setLayout(new GridLayout(3, false));
		
		lblNewLabel_4 = new Label(group, SWT.NONE);
		lblNewLabel_4.setBounds(0, 0, 61, 17);
		lblNewLabel_4.setText("第一鉴定人");
		
		text_4 = new Text(group, SWT.BORDER);
		text_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		text_4.setBounds(0, 0, 73, 23);
		
		combo = new Combo(group, SWT.NONE);
		combo.setItems(new String[] {"%", "￥"});
		combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		combo.setBounds(0, 0, 88, 25);
		
		Label lblNewLabel_5 = new Label(group, SWT.NONE);
		lblNewLabel_5.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel_5.setText("第二鉴定人");
		
		text_5 = new Text(group, SWT.BORDER);
		text_5.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		
		combo_1 = new Combo(group, SWT.NONE);
		combo_1.setItems(new String[] {"%", "￥"});
		combo_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		
		Label lblNewLabel_6 = new Label(group, SWT.NONE);
		lblNewLabel_6.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel_6.setText("第三鉴定人");
		
		text_6 = new Text(group, SWT.BORDER);
		text_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		combo_2 = new Combo(group, SWT.NONE);
		combo_2.setItems(new String[] {"%", "￥"});
		combo_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		lblNewLabel_7 = new Label(group, SWT.NONE);
		lblNewLabel_7.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel_7.setText("复核人");
		
		text_7 = new Text(group, SWT.BORDER);
		text_7.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		combo_3 = new Combo(group, SWT.NONE);
		combo_3.setItems(new String[] {"%", "￥"});
		combo_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		lblNewLabel_8 = new Label(group, SWT.NONE);
		lblNewLabel_8.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel_8.setText("签发人");
		
		text_8 = new Text(group, SWT.BORDER);
		text_8.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		combo_4 = new Combo(group, SWT.NONE);
		combo_4.setItems(new String[] {"%", "￥"});
		combo_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		lblNewLabel_9 = new Label(group, SWT.NONE);
		lblNewLabel_9.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel_9.setText("助理");
		
		text_9 = new Text(group, SWT.BORDER);
		text_9.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		combo_5 = new Combo(group, SWT.NONE);
		combo_5.setItems(new String[] {"%", "￥"});
		combo_5.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		lblNewLabel_10 = new Label(group, SWT.NONE);
		lblNewLabel_10.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel_10.setText("文书编辑");
		
		text_10 = new Text(group, SWT.BORDER);
		text_10.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		combo_6 = new Combo(group, SWT.NONE);
		combo_6.setItems(new String[] {"%", "￥"});
		combo_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		lblNewLabel_11 = new Label(shell, SWT.NONE);
		lblNewLabel_11.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel_11.setText("备注");
		
		text_11 = new Text(shell, SWT.BORDER);
		text_11.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
		new Label(shell, SWT.NONE);
		new Label(shell, SWT.NONE);
		
		btnNewButton = new Button(shell, SWT.NONE);
		btnNewButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				ChargeItemService service=new ChargeItemService();
				System.out.println(chargeItem.getCategory());
				service.insert(chargeItem);
				result=true;
				shell.close();
			}
		});
		btnNewButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		btnNewButton.setText("保存");
		
		btnNewButton_1 = new Button(shell, SWT.NONE);
		btnNewButton_1.addSelectionListener(new CloseDialogSelectionAdapter());
		GridData gd_btnNewButton_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
		gd_btnNewButton_1.widthHint = 82;
		btnNewButton_1.setLayoutData(gd_btnNewButton_1);
		btnNewButton_1.setText("关闭");
		m_bindingContext = initDataBindings();

	}
	protected DataBindingContext initDataBindings() {
		DataBindingContext bindingContext = new DataBindingContext();
		//
		IObservableValue observeTextTextObserveWidget = WidgetProperties.text(SWT.Modify).observe(text);
		IObservableValue nameChargeItemObserveValue = PojoProperties.value("name").observe(chargeItem);
		bindingContext.bindValue(observeTextTextObserveWidget, nameChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_1ObserveWidget = WidgetProperties.text(SWT.Modify).observe(text_1);
		IObservableValue unitChargeItemObserveValue = PojoProperties.value("unit").observe(chargeItem);
		bindingContext.bindValue(observeTextText_1ObserveWidget, unitChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_2ObserveWidget = WidgetProperties.text(SWT.Modify).observe(text_2);
		IObservableValue baseFeeChargeItemObserveValue = PojoProperties.value("baseFee").observe(chargeItem);
		bindingContext.bindValue(observeTextText_2ObserveWidget, baseFeeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_3ObserveWidget = WidgetProperties.text(SWT.Modify).observe(text_3);
		IObservableValue standardFeeChargeItemObserveValue = PojoProperties.value("standardFee").observe(chargeItem);
		bindingContext.bindValue(observeTextText_3ObserveWidget, standardFeeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_4ObserveWidget = WidgetProperties.text(SWT.Modify).observe(text_4);
		IObservableValue appraiser1FeeChargeItemObserveValue = PojoProperties.value("appraiser1Fee").observe(chargeItem);
		bindingContext.bindValue(observeTextText_4ObserveWidget, appraiser1FeeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextComboObserveWidget = WidgetProperties.text().observe(combo);
		IObservableValue appraiser1TypeChargeItemObserveValue = PojoProperties.value("appraiser1Type").observe(chargeItem);
		bindingContext.bindValue(observeTextComboObserveWidget, appraiser1TypeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_5ObserveWidget_1 = WidgetProperties.text(SWT.Modify).observe(text_5);
		IObservableValue appraiser2FeeChargeItemObserveValue = PojoProperties.value("appraiser2Fee").observe(chargeItem);
		bindingContext.bindValue(observeTextText_5ObserveWidget_1, appraiser2FeeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextCombo_1ObserveWidget_1 = WidgetProperties.text().observe(combo_1);
		IObservableValue appraiser2TypeChargeItemObserveValue = PojoProperties.value("appraiser2Type").observe(chargeItem);
		bindingContext.bindValue(observeTextCombo_1ObserveWidget_1, appraiser2TypeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_6ObserveWidget = WidgetProperties.text(SWT.Modify).observe(text_6);
		IObservableValue appraiser3FeeChargeItemObserveValue = PojoProperties.value("appraiser3Fee").observe(chargeItem);
		bindingContext.bindValue(observeTextText_6ObserveWidget, appraiser3FeeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextCombo_2ObserveWidget = WidgetProperties.text().observe(combo_2);
		IObservableValue appraiser3TypeChargeItemObserveValue = PojoProperties.value("appraiser3Type").observe(chargeItem);
		bindingContext.bindValue(observeTextCombo_2ObserveWidget, appraiser3TypeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_7ObserveWidget = WidgetProperties.text(SWT.Modify).observe(text_7);
		IObservableValue reviwerFeeChargeItemObserveValue = PojoProperties.value("reviwerFee").observe(chargeItem);
		bindingContext.bindValue(observeTextText_7ObserveWidget, reviwerFeeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextCombo_3ObserveWidget = WidgetProperties.text().observe(combo_3);
		IObservableValue reviwerTypeChargeItemObserveValue = PojoProperties.value("reviwerType").observe(chargeItem);
		bindingContext.bindValue(observeTextCombo_3ObserveWidget, reviwerTypeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_8ObserveWidget = WidgetProperties.text(SWT.Modify).observe(text_8);
		IObservableValue signerFeeChargeItemObserveValue = PojoProperties.value("signerFee").observe(chargeItem);
		bindingContext.bindValue(observeTextText_8ObserveWidget, signerFeeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextCombo_4ObserveWidget = WidgetProperties.text().observe(combo_4);
		IObservableValue signerTypeChargeItemObserveValue = PojoProperties.value("signerType").observe(chargeItem);
		bindingContext.bindValue(observeTextCombo_4ObserveWidget, signerTypeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_9ObserveWidget = WidgetProperties.text(SWT.Modify).observe(text_9);
		IObservableValue assistantFeeChargeItemObserveValue = PojoProperties.value("assistantFee").observe(chargeItem);
		bindingContext.bindValue(observeTextText_9ObserveWidget, assistantFeeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextCombo_5ObserveWidget = WidgetProperties.text().observe(combo_5);
		IObservableValue assistantTypeChargeItemObserveValue = PojoProperties.value("assistantType").observe(chargeItem);
		bindingContext.bindValue(observeTextCombo_5ObserveWidget, assistantTypeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_10ObserveWidget = WidgetProperties.text(SWT.Modify).observe(text_10);
		IObservableValue editorFeeChargeItemObserveValue = PojoProperties.value("editorFee").observe(chargeItem);
		bindingContext.bindValue(observeTextText_10ObserveWidget, editorFeeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextCombo_6ObserveWidget = WidgetProperties.text().observe(combo_6);
		IObservableValue editorTypeChargeItemObserveValue = PojoProperties.value("editorType").observe(chargeItem);
		bindingContext.bindValue(observeTextCombo_6ObserveWidget, editorTypeChargeItemObserveValue, null, null);
		//
		IObservableValue observeTextText_11ObserveWidget = WidgetProperties.text(SWT.Modify).observe(text_11);
		IObservableValue commentChargeItemObserveValue = PojoProperties.value("comment").observe(chargeItem);
		bindingContext.bindValue(observeTextText_11ObserveWidget, commentChargeItemObserveValue, null, null);
		//
		return bindingContext;
	}
}
